﻿using Microsoft.Extensions.DependencyInjection;
using Sdari.Example.Models;

namespace Sdari.Example.Services;

public static class ExampleServicesExtensions
{
    /// <summary>
    ///     写入Service的Extension，防止直接创建Service实例
    /// </summary>
    /// <param name="services"></param>
    /// <returns></returns>
    public static IServiceCollection AddExampleServices(this IServiceCollection services)
    {
        return services
            //数据库
            .AddExampleDbContext()
            //Todo 应该是单例，考虑修改设计模式
            //Todo 能不能避免使用实例类
            .AddScoped<IExampleService, ExampleService>();
    }
}